import com.hngc.util.DBUtil;
import org.junit.Test;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class MyTest1 {


    @Test
    public void testConn() throws Exception {
        Connection conn = DBUtil.getConnection();
        String sql = "select * from t_user";
        //预编译sql语句
        PreparedStatement pstmt = conn.prepareStatement(sql);
        //执行查询，并将返回结果赋给结果集
        ResultSet rs = pstmt.executeQuery();

        //循环取出结果集中的数据
        while (rs.next()) {
            System.out.println(rs.getInt("id") + "," + rs.getString("name") + ","
                    + rs.getInt("age") + "," + rs.getString("hiredate"));
        }


    }

}
